package com.cn.rocketmq.controller;

import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description :
 * @Author : Bruce Lee
 * @CreateTime : 2024/7/22
 */

@RestController
@Slf4j
public class ProduceController {

    @Autowired
    private RocketMQTemplate rocketmqTemplate;

    @GetMapping("/test")
    public void test() {
        Message<String> msg = MessageBuilder.withPayload("Welcome, jxsr").build();
        rocketmqTemplate.send("jxsr", msg);
        log.info("消息发送成功");
    }

}
